package com.example.http

import android.os.Bundle
import android.util.Log
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.lifecycle.lifecycleScope
import com.example.http.two.MallApi
import com.example.http.two.RetrofitManager
import kotlinx.coroutines.launch
import okhttp3.MediaType
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.RequestBody.Companion.toRequestBody

const val TAG = "MainActivity"
class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContentView(R.layout.activity_main)

//        lifecycleScope.launch {
//            val baseResponse = RetrofitManager.getInstance()
//                .create(Api::class.java)
//                .appUpdate()
//            Log.d(TAG, "onCreate: ${baseResponse.data}")
//
//        }

        lifecycleScope.launch {
            val json = "{\"adType\":\"skl_app_start\"}"
            val mediaType = "application/json; charset=utf-8".toMediaType()
            val requestBody = json.toRequestBody(mediaType)

            RetrofitManager.getInstance().create(MallApi::class.java)
                .getAdInfo(requestBody)
        }




    }
}